<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Controller;

use App\Exception\BusinessException;
use Hyperf\Logger\LoggerFactory;
use Psr\Log\LoggerInterface;

class IndexController extends AbstractController
{

    protected LoggerInterface $logger;

    public function __construct(LoggerFactory $loggerFactory)
    {
        $this->logger = $loggerFactory->get('log', 'default');
    }

    public function index(): \Psr\Http\Message\ResponseInterface
    {
        var_dump(config('databases.default.log'));
        $user = $this->request->input('user', 'Hyperf');
        $method = $this->request->getMethod();
        if ($user === 'ling') {
            throw new BusinessException();
        }
        return $this->respJson(data: [
            'method' => $method,
            'message' => "Hello {$user}.",
        ]);
    }

    public function test()
    {
        $user = $this->request->input('user', 'Hyperf');
        var_dump($user->aa);
    }
}
